//
//  YearDetailView.swift
//  MakeMoney
//
//  Created by Fan ZhiQiang on 2024/12/19.
//

import SwiftUI

struct YearDetailView: View {
    @Bindable var pathStore: PathStore
    let year: Int
    @State private var lotterys: [Lottery] = []
    var body: some View {
        LotterysView(lotterys: lotterys)
            .toolbar {
                ToolbarItem(placement: .topBarTrailing) {
                    Button("统计") {
                        pathStore.path.append(YearStatisticPath())
                    }
                }
            }
            .navigationTitle(String(year) + "年")
            .navigationDestination(for: YearStatisticPath.self) { _ in
                YearStatisticView(pathStore: pathStore, year: year)
            }
            .onAppear {
                lotterys = getLotterysWith(range: getYearIdRange(with: year))
            }
    }
}

#Preview {
    YearDetailView(pathStore: .init(), year: 2024)
}

class YearDetailPath: PathName { }
